"""
异常处理
"""


class MyException(BaseException):
    def __init__(self, errcode, errmsg):
        self.errcode = errcode
        self.errmsg = errmsg


def input_num():
    try:
        num = int(input("请输入数字："))
    except Exception as e:
        print("输入的不是数字，请重新输入...")
        raise MyException(100, "输入的不是数字：" + format(e))
    finally:
        print("完事....")


def main():
    while True:
        try:
            input_num()
        except MyException as e:
            print(e)
            print("输入异常！错误编码为%d，错误信息为%s" % (e.errcode, e.errmsg))
        except:
            # 其它抛出异常
            raise


main()
